var gulp = require('gulp');
var less = require('gulp-less');
var concat = require('gulp-concat');
var server = require('gulp-connect');
var autoPre = require('gulp-autoprefixer');

gulp.task('default',['watch'],function() {
    // 将你的默认的任务代码放在这
});

gulp.task('concat_js',function () {
    gulp.src(['public/js/moudle/common.js','public/js/moudle/index.js'])
        .pipe(concat('indexAll.js'))
        .pipe(gulp.dest('public/js'));
    gulp.src(['public/js/moudle/common.js','public/js/moudle/collection.js'])
        .pipe(concat('collectionAll.js'))
        .pipe(gulp.dest('public/js'));
});
gulp.task('all_less',function () {
    gulp.src(['public/less/*.less','public/less/*/*.less'])
        .pipe(less())
        .pipe(concat("css.css"))
        .pipe(autoPre({
            browsers: ['last 2 versions'],
            cascade: false
        }))
        .pipe(gulp.dest('public/css'));
});

gulp.task('reload',['concat_js','all_less'],function () {
    return gulp.src('public/index.html')
        .pipe(server.reload());
});

gulp.task('watch',function () {
    gulp.watch(['public/*.html','public/less/*.less','public/less/*/*.less','public/index.html','public/js/*/*.js'],['reload']);
});
